package tazadum.engine.util;

import tazadum.engine.math.Vector;
import tazadum.engine.math.noise.ImprovedPerlin3d;

public class HeightMap {
	private final Vector offset;
	private final float scale;
	private final float amplitude;

	public HeightMap(final Vector offset, final float scale, final float amplitude) {
		this.offset = offset;
		this.scale = scale;
		this.amplitude = amplitude;
	}

	public void shift(final float offsetY) {
		offset.y = offsetY;
	}

	public float at(final float x, final float z) {
		final float xp = (x + offset.x) * scale;
		final float zp = (z + offset.z) * scale;
		return (float) ImprovedPerlin3d.noise(xp, offset.y, zp) * amplitude;
	}

	public float raw(final float x, final float z) {
		final float xp = (x + offset.x) * scale;
		final float zp = (z + offset.z) * scale;
		return (float) ImprovedPerlin3d.noise(xp, offset.y, zp);
	}
}
